import type { ComponentProps } from "svelte";

export function useClassList (props: ComponentProps<any>, ...customClassList: any) {
    const obj: any = {};
    if (props.class) {
        if (typeof props.class === 'string') {
            obj[props.class] = true;
        } else {
            for (const key in props.class) {
                obj[key] = props.class[key];
            }
        }
    }
    if (customClassList) {
        for (let i = 0; i < customClassList.length; i++) {
            const item = customClassList[i];
            if (typeof item === 'string') {
                obj[item] = true;
            } else {
                for (const key in item) {
                    obj[key] = item[key];
                }
            }
        }
    }
    return obj;
}